#include "stdafx.h"
#include "ToolServiceInstaller.h"

#include <winsvc.h>

SERVICE_STATUS ServiceStatus; 
  
void InstallSvc(LPTSTR lpSvcName, LPTSTR lpExePath)
{
    // Get a handle to the SCM database
    // Code goes here
	SC_HANDLE schSCManager;
	SC_HANDLE schService;

	schSCManager = OpenSCManager(
        NULL,                    // local computer
        NULL,                    // ServicesActive database
        SC_MANAGER_ALL_ACCESS);  // full access rights
	if (NULL == schSCManager)
    {
        //Log error here
        return;
    }
    // Create the service
    // Code goes here
	 schService = CreateService(
        schSCManager,          // SCM database
        lpSvcName,             // name of service
		lpSvcName,            // displayname of service
		SERVICE_ALL_ACCESS,
		SERVICE_WIN32_OWN_PROCESS,
		SERVICE_DISABLED,
		SERVICE_ERROR_NORMAL,
		lpExePath,
		NULL,
		NULL,
		NULL,
		NULL,
		NULL);
 
    if (schService == NULL)
    {
        //Log error here

        CloseServiceHandle(schSCManager);
        return;
    }else
	{
		 //Log success info here
		return;
	}

}


void LogFile(LPTSTR lpData)
{
}